{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "19c19ef8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from math import sqrt\n",
    "\n",
    "sqrt(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "807f8ab6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "-4 can't be square rooted\n"
     ]
    }
   ],
   "source": [
    "def square_root(func):\n",
    "    def inner_func(x):\n",
    "        if x <=0:\n",
    "            return F\"{x} can't be square rooted\"\n",
    "        return func(x)\n",
    "    return inner_func\n",
    "\n",
    "@square_root\n",
    "def sqrt2(x):\n",
    "    return int(sqrt(x))\n",
    "\n",
    "print(sqrt2(4))\n",
    "print(sqrt2(-4))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3d94f0b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "def raiz_valor_absoluto(func):\n",
    "    def inner_func(x):\n",
    "        if x<0:\n",
    "            return func(-x)\n",
    "        else:\n",
    "            return func(x)\n",
    "    return inner_func\n",
    "        \n",
    "@raiz_valor_absoluto\n",
    "def sqrt3(x):\n",
    "    return int(sqrt(x))\n",
    "\n",
    "print(sqrt3(-4))\n",
    "print(sqrt3(-9))\n",
    "print(sqrt3(4))\n",
    "print(sqrt3(9))\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73aa84bd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
